unit uTemplet;

interface

uses
  Windows, SysUtils,db, ADODB,Dialogs, Controls,forms, Classes,uGlobal,uShare,uTemplet_head;

  type
    TGetEventMng = function (AForm: TForm; pFormState:Pointer;AGetValueProc:TGetGlobalValueProc):TEventMng;stdcall;
    TInitProcDll =  procedure (p_con:TADOConnection;p_app:TApplication; p_GetSysGlobalValue:TGetSysGlobalValue);stdcall;

    function GetEventMng(AForm: TForm; pFormState:Pointer;AGetValueProc:TGetGlobalValueProc):TEventMng;stdcall;
    procedure InitTempLetProcDll(p_con:TADOConnection;p_app:TApplication; p_GetSysGlobalValue:TGetSysGlobalValue);stdcall;
                                                                          
    procedure LoadTempLetDll;
const
  TempLetDLL = 'TempLet.dll'  ;
var
  Handle_TempLet:THandle;
  dllGetEventMng: TGetEventMng;
  dllInitProcDll : TInitProcDll;
implementation

procedure LoadTempLetDll;
begin
  Handle_TempLet := LoadLibrary(TempLetDLL); 
  dllGetEventMng:= GetProcAddress(Handle_TempLet, 'GetEventMng');
  dllInitProcDll:= GetProcAddress(Handle_TempLet, 'InitProcDll');
end;

procedure InitTempLetProcDll(p_con:TADOConnection;p_app:TApplication; p_GetSysGlobalValue:TGetSysGlobalValue);
begin
  dllInitProcDll(p_con,p_app,p_GetSysGlobalValue) ;
end;

function GetEventMng(AForm: TForm; pFormState:Pointer;AGetValueProc:TGetGlobalValueProc):TEventMng;
begin
  try
    Result := dllGetEventMng(AForm,pFormState,AGetValueProc);
  except
    on e:exception do
    begin
      raise exception.Create('DLL Exception:'+e.Message)
    end;
  end;
end; 

end.
